﻿<UserControl x:Class="TaskbarConcepts.Overlays"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             xmlns:local="clr-namespace:TaskbarConcepts">
  <UserControl.Resources>
    <local:IconToBitmapSourceConverter x:Key="IconToBitmapSourceConverter" />
    <DataTemplate x:Key="ImageTemplate">
      <Grid>
        <Image Source="{Binding Converter={StaticResource IconToBitmapSourceConverter}, Mode=Default}"/>
      </Grid>
    </DataTemplate>
    <ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
      <VirtualizingStackPanel IsItemsHost="True" Orientation="Horizontal"/>
    </ItemsPanelTemplate>
    <SolidColorBrush x:Key="ListBoxItemUnselected" Color="#002685E2" />
    <SolidColorBrush x:Key="ListBoxItemSelected" Color="#FF2685E2" />
    <Style x:Key="ListBoxItemStyle1" TargetType="{x:Type ListBoxItem}">
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
      <Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
      <Setter Property="Padding" Value="2,0,0,0"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type ListBoxItem}">
            <Border x:Name="Bd" SnapsToDevicePixels="true"
                    Background="{TemplateBinding Background}"
                    Padding="{TemplateBinding Padding}" HorizontalAlignment="Center"
                    VerticalAlignment="Center"
                    BorderBrush="{DynamicResource ListBoxItemUnselected}" BorderThickness="2">
              <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
            </Border>
            <ControlTemplate.Triggers>
              <Trigger Property="IsSelected" Value="true">
                <Setter Property="BorderBrush" TargetName="Bd" Value="{DynamicResource ListBoxItemSelected}"/>
              </Trigger>
              <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
              </Trigger>
            </ControlTemplate.Triggers>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
  </UserControl.Resources>
  <Grid>
    <Grid Margin="2" Width="200" VerticalAlignment="Top">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" MinHeight="50"/>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>
      <Rectangle Style="{DynamicResource BorderStyle}" Grid.RowSpan="4" />
      <TextBlock Text="Overlay Icons"
                 Margin="{DynamicResource BoxedContentMargin}"
                 Style="{DynamicResource SectionTitle}" />
      <ListBox x:Name="iconsList"
               Margin="{DynamicResource BoxedContentMargin}"
               Grid.Row="1" ItemTemplate="{DynamicResource ImageTemplate}"
               ItemsPanel="{DynamicResource ItemsPanelTemplate1}"
               ItemContainerStyle="{DynamicResource ListBoxItemStyle1}"
               SelectionChanged="iconsList_SelectionChanged" />
      <CheckBox x:Name="ShowOverlay" Click="ShowOverlay_Click" Grid.Row="2"
                Margin="{DynamicResource BoxedContentMargin}">
        <TextBlock Text="Show selected icon as overlay"  TextWrapping="Wrap" />
      </CheckBox>
    </Grid>
  </Grid>
</UserControl>
